<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>展览管理</title>
    <c:set var="contextPath" value="${pageContext.request.contextPath}" scope="request"/>
	<link rel="stylesheet" href="${contextPath}/static-resources/css/index.css"/>
	<script src="${contextPath}/static-resources/jquery-1.12.1.js"></script>
	<script src="${contextPath}/static-resources/js/index.js"></script>
	
	<link rel="stylesheet" type="text/css" href="${contextPath}/static-resources/themes/material/easyui.css">
	<link rel="stylesheet" type="text/css" href="${contextPath}/static-resources/themes/icon.css">
	<script type="text/javascript" src="${contextPath}/static-resources/jquery.min.js"></script>
	<script type="text/javascript" src="${contextPath}/static-resources/jquery.easyui.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$('#hallTable').datagrid({
				onDblClickRow: function(index,row){
					console.log(row.logo);
				}
			});
		})
		
		function hallFieldFormatter(value){
			if (!value) {
				return "";
			}
			return value.name;
		}

		function addHome() {
			var hallId = $('#hallCombobox').combobox('getValue');
			var name = $('#homeName').textbox('getValue');
			var address = $('#homeAddress').textbox('getValue');
			if (!name) {
				showInfo("展厅名称不能为空");
				return;
			}
			if (!hallId) {
				showInfo("所属展馆不能为空");
				return;
			}
			
			openMask();
			$.ajax({
				type : "POST",
				url : '${contextPath}/exhibitionHome/add.do',
				data : {"name" : name, "address" : address, "hallId" : hallId},
				success : function(data) {
					if (data.status) {
						$('#addHomeWin').window('close');
						$('#homeTable').datagrid('reload');
					} else {
						showError(data.message);
					}
					closeMask();
				},
				error : function() {
					showError('系统异常');
					closeMask();
				}
			});
		}

		// 添加展馆
		function addHall() {
			var name = $('#hallName').textbox('getValue');
			var address = $('#hallAddress').textbox('getValue');
			if (name.length <= 0) {
				showWarn('展馆名称不能为空');
				return;
			}
			openMask();
			$.ajax({
				type : "POST",
				url : '${contextPath}/exhibitionHall/add.do',
				data : {
					"name" : name,
					"address" : address
				},
				success : function(data) {
					if (data.status) {
						$('#addHallWin').window('close');
						$('#hallTable').datagrid('reload');
					} else {
						showError(data.message);
					}
					closeMask();
				},
				error : function() {
					showError('系统异常');
					closeMask();
				}
			});
		}
		
		function removeHall() {
			
		}
	</script>
</head>
<body style="height: 100%;">
	<div class="find_nav">
	    <div class="find_nav_left">
	        <div class="find_nav_list">
	            <ul>
                	<li><a href="javascript:void(0)" url="${contextPath}/exhibition/index.do">展览</a></li>
	                <li class="selected"><a href="javascript:void(0)" url="${contextPath}/exhibitionHome/index.do">展厅</a></li>
	                <li><a href="javascript:void(0)" url="${contextPath}/production/index.do">作品</a></li>
	                <li><a href="javascript:void(0)" url="${contextPath}/image/index.do">图片</a></li>
	                <li><a href="javascript:void(0)" url="${contextPath}/user/index.do">用户</a></li>
	                <li><a href="javascript:void(0)" url="${contextPath}/banner/index.do">banner</a></li>
	                <li class="sideline"></li>
	            </ul>
	        </div>
	    </div>
	</div>
	<div id="content" style="width: 100%; position: absolute;top: 45px;">
		<div class="easyui-layout" style="width:100%;height:100%;">
			<div data-options="region:'west',split:true" title="展馆" style="width:50%">
				<table id="hallTable" class="easyui-datagrid" style="width:100%;height:100%;"
					data-options="rownumbers:true, singleSelect:true, url:'${contextPath}/exhibitionHall/listJson.do',method:'get', toolbar:'#hallTableTB' " >
					<thead>
						<tr>
							<th data-options="field:'ck', checkbox:true"></th>
							<th data-options="field:'name', width:'25%' ">名称</th>
							<th data-options="field:'address', width:'35%'">详细地址</th>
							<th data-options="field:'createTime', width:'35%'" formatter ="dateTimeFormatter" >创建时间</th>
						</tr>
					</thead>
				</table>
			</div>
			
			<div data-options="region:'center',title:'展厅'">
				<table id="homeTable" class="easyui-datagrid" style="width:100%;height:100%;"
					data-options="rownumbers:true, singleSelect:true, url:'${contextPath}/exhibitionHome/listJson.do',method:'get', toolbar:'#homeTableTB' " >
					<thead>
						<tr>
							<th data-options="field:'ck', checkbox:true"></th>
							<th data-options="field:'name', width:'20%' ">名称</th>
							<th data-options="field:'address', width:'30%'">详细地址</th>
							<th data-options="field:'hall', width:'30%'", formatter = "hallFieldFormatter">所属展馆</th>
							<th data-options="field:'createTime', width:'10%'" formatter ="dateTimeFormatter" >创建时间</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
		
		<div id="hallTableTB">
			<a href="#" class="easyui-linkbutton" iconCls="icon-sum" plain="true" onclick="$('#hallTable').datagrid('reload')">查询所有</a>
         	<span class="datagrid-btn-separator" style="vertical-align: middle;display:inline-block;float:none"></span>
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="$('#addHallWin').window('open');">添加</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="">编辑</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeHall()">删除</a>
		</div>
		
		<div id="homeTableTB">
			<a href="#" class="easyui-linkbutton" iconCls="icon-sum" plain="true" onclick="$('#homeTable').datagrid('reload');">查询所有</a>
         	<span class="datagrid-btn-separator" style="vertical-align: middle;display:inline-block;float:none"></span>
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="$('#addHomeWin').window('open'); $('#hallCombobox').combobox('reload');">添加</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editExhibition()">编辑</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeHome()">删除</a>
		</div>
		
		<div id="addHallWin" class="easyui-window" title="添加展馆" data-options="iconCls:'icon-add', collapsible:'false', modal:'true', closed:true, footer:'#addHallWinFooter'" style="width:400px; height:230px; padding:10px;" >
			<div style="margin-bottom:5px">
				<input class="easyui-textbox" data-options="label: '名称：', labelPosition:'before'" id="hallName" style="width: 100%;"/>
			</div>
			<div style="margin-bottom:5px">
				<input class="easyui-textbox" data-options="label: '详细地址：', labelPosition:'before'" id="hallAddress" style="width: 100%;"/>
			</div>
		</div>
		
		<div id="addHallWinFooter" class="windowFooter">
			<a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="addHall()">确定</a>  
            <a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="$('#addHallWin').window('close')">取消</a>  
		</div>
		
		<!-- ##############下面是添加展览相关的窗体############## -->
		<div id="addHomeWin" class="easyui-window" title="添加展厅" data-options="iconCls:'icon-add', collapsible:'false', modal:'true', closed:true, footer:'#addHomeWinFooter'" style="width:450px; height:350px; padding:10px;" >
			<div style="margin-bottom:5px">
				<select class="easyui-combobox" id="hallCombobox" style="width:100%;" data-options="label: '所属展馆：', labelPosition:'before', url:'${contextPath}/exhibitionHall/listJson.do',method:'get', valueField:'id', textField:'name'"></select>
			</div>
			<div style="margin-bottom:5px">
				<input class="easyui-textbox" data-options="label: '名称：', labelPosition:'before'" id="homeName" style="width: 100%;"/>
			</div>
			<div style="margin-bottom:5px">
				<input class="easyui-textbox" data-options="label: '详细地址：', labelPosition:'before'" id="homeAddress" style="width: 100%;"/>
			</div>
		</div>
		
		<div id="addHomeWinFooter" class="windowFooter">
			<a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="addHome()">确定</a>  
            <a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="$('#addHomeWin').window('close')">取消</a>  
		</div>
		
	</div>
</body>


</html>